package net.sxnic.ugr.dept.taglib;

import java.io.IOException;
import java.util.Set;

import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

import net.sxnic.ugr.dept.Dept;

import org.apache.commons.lang.StringUtils;

/**
 * 
 * Introduction：遍历depts 输出部门简称的序列
 * @author 孙宇飞
 * create date : 2010-7-1
 */
public class DeptIteratorNameTag extends BodyTagSupport{

	private static final long serialVersionUID = 8362916037651739420L;

	private Set<Dept> depts;
	
	public int doEndTag() {
		JspWriter out = pageContext.getOut();
		
		try {
			if(depts == null || depts.size()<=0){
				out.print("");
			}else{
				String temp = "";
				for(Dept u:depts){
					temp = temp + u.getName()+",";
				}
				out.print(StringUtils.removeEnd(temp, ","));
			}
			
		} catch (IOException e) {
			
		}

		return EVAL_PAGE;
	}

	public Set<Dept> getDepts() {
		return depts;
	}

	public void setDepts(Set<Dept> depts) {
		this.depts = depts;
	}

	

}
